/**
 * 
 */
package com.miolr.core.dao.jpa;

import java.io.Serializable;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaQuery;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.springframework.beans.factory.annotation.Autowired;

import com.miolr.core.dao.AbstractGenericDao;
import com.miolr.core.query.PageModel;

/**
 * @author iday
 * 
 */
public class JpaGenericDao<T> extends AbstractGenericDao<T> {

	@Autowired
	private EntityManager entityManager;

	/**
	 * @param entityManager
	 *            the entityManager to set
	 */
	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.miolr.core.dao.GenericDao#queryAll(com.miolr.core.query.PageModel,
	 * boolean, java.lang.String)
	 */
	@Override
	public List<T> queryAll(PageModel pm, boolean cached, String cacheRegion) {
		CriteriaQuery<T> c = entityManager.getCriteriaBuilder().createQuery(
				persistentClass);
		return entityManager.createQuery(c).setFirstResult(pm.getFirstRecord())
				.setMaxResults(pm.getMaxRecord()).getResultList();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#queryAll(org.hibernate.criterion.
	 * DetachedCriteria, com.miolr.core.query.PageModel, boolean,
	 * java.lang.String)
	 */
	@Override
	public List<T> queryAll(DetachedCriteria detachedCriteria, PageModel pm,
			boolean cached, String cacheRegion) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#queryAll(java.lang.String,
	 * com.miolr.core.query.PageModel)
	 */
	@Override
	public List<T> queryAll(String sql, PageModel pm) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#queryAll(java.lang.String,
	 * com.miolr.core.query.PageModel, boolean)
	 */
	@Override
	public List<T> queryAll(String sql, PageModel pm, boolean cached) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#queryAll(java.lang.String)
	 */
	@Override
	public List<T> queryAll(String sql) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#queryAll(java.lang.String, boolean)
	 */
	@Override
	public List<T> queryAll(String sql, boolean cached) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#deleteAll(java.util.Collection)
	 */
	@Override
	public void deleteAll(Collection<T> c) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#delete(java.lang.Object)
	 */
	@Override
	public void delete(T obj) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.miolr.core.dao.GenericDao#deleteByPrimaryKey(java.io.Serializable)
	 */
	@Override
	public void deleteByPrimaryKey(Serializable key) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#saveOrUpdate(java.util.Collection)
	 */
	@Override
	public void saveOrUpdate(Collection<T> c) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#merge(java.lang.Object)
	 */
	@Override
	public void merge(T t) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#update(java.lang.Object)
	 */
	@Override
	public void update(T obj) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#save(java.lang.Object)
	 */
	@Override
	public void save(T obj) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#findAll()
	 */
	@Override
	public List<T> findAll() {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#findByPrimaryKey(java.io.Serializable)
	 */
	@Override
	public T findByPrimaryKey(Serializable key) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#initLazeProperties(java.lang.Object,
	 * java.lang.String[])
	 */
	@Override
	public void initLazeProperties(Object t, String... nestedNames) {
		// TODO Auto-generated method stub

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#count(org.hibernate.Criteria)
	 */
	@Override
	public Long count(Criteria criteria) {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see com.miolr.core.dao.GenericDao#findOne(org.hibernate.criterion.
	 * DetachedCriteria, boolean)
	 */
	@Override
	public T findOne(DetachedCriteria detachedCriteria, boolean cached) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Iterator<T> iterate(String sql, Object param) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Iterator<T> iterate(String sql) {
		// TODO Auto-generated method stub
		return null;
	}

}
